package com.myproject.music.service.impl;

import com.myproject.music.BizException;
import com.myproject.music.domain.Order;
import com.myproject.music.mapper.OrderMapper;
import com.myproject.music.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    private static final Logger log = LoggerFactory.getLogger(OrderServiceImpl.class);
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> selectOrderAll() {
        return orderMapper.selectOrderAll();
    }

    @Override
    public Order selectOrderById(Long id) {
        Order order =orderMapper.selectOrderById(id);
        if(order ==null){
            log.error("该专辑"+id+"不存在");
            throw new BizException("该专辑"+id+"不存在");
        }
        log.info("查询专辑"+id+"成功");
        return orderMapper.selectOrderById(id);
    }

    @Override
    public List<Order> selectOrderByParam(String orderName) {
        return orderMapper.selectOrderByParam(orderName);
    }

    @Override
    public int insertOrder(Order order) {
        return orderMapper.insertOrder(order);
    }

    @Override
    public int updateOrder(Order order) { return orderMapper.updateOrder(order); }

    @Override
    public int deleteOrderById(Long id) {
        return orderMapper.deleteOrderById(id);
    }
}
